package com.jufanshare.myblog.common.mvc;

import com.jufanshare.myblog.entity.Account;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 作用：
 * 作者：Tiddler
 * 时间：2019/1/27 09：46
 * 类名： SessionHandlerIntercepter
 **/
public class SessionHandlerInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        // TODO Auto-generated method stub
        Account account=(Account) request.getSession().getAttribute("account_session_key");
        if(account==null){
            response.sendRedirect("/blog/yzq/login");
        }
        return true;
    }
}
